<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper1">
    <!-- slides -->
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" />
      </swiper-slide>
      <!-- <swiper-slide>
        <img class="swiper-img" src="//img1.qunarzz.com/sight/p0/1507/d4/f8ac1f83c6911b40f31ee560e8ab5a1b.water.jpg_600x330_55810851.jpg" />
      </swiper-slide> -->
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
      <!-- 不需要左右箭头 -->
      <!-- <div class="swiper-button-prev" slot="button-prev"></div>
      <div class="swiper-button-next" slot="button-next"></div> -->
      <!-- 去掉最下面的灰色条 -->
      <div class="swiper-scrollbar"   slot="scrollbar"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  computed: {
    showSwiper1 () {
      return this.list.length;
    }
  }
}
</script>

<style lang="stylus" scoped>
  /* 对样式进行穿透 */
  .wrapper >>> .swiper-pagination-bullet-active
      background: #ffffff
  .wrapper
    overflow: hidden
    width: 100%
    height: 0
    padding-bottom: 30%
    background: #eee
    .swiper-img
      width: 100%
</style>
